package com.tuo51.evaluate.domain.tags;

import com.tuo51.foudation.model.Model;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import java.io.Serializable;

@Entity
@Data
@Table(name = "mrel_object_tag", uniqueConstraints = {
        @UniqueConstraint(columnNames = {
                "tagId", "objId", "objType"
        })
} )
public class RelObjectTag extends Model implements Serializable {
  private static final long serialVersionUID = 1L;

  @Column(columnDefinition = "varchar(32) COMMENT 'tag id'", nullable = false)
  private String tagId;

  @Column(columnDefinition = "varchar(32) COMMENT '对象id'", nullable = false, unique = true)
  private String objId;

  @Column(name = "objType", columnDefinition = "int default 0 COMMENT '对象类型， 1.question  2. storeItem   3.dimension   4.newsItem'", nullable = false)
  private Integer objType;

  public static RelObjectTag of(String tagId, String objId, Integer objType){
    RelObjectTag ret = new RelObjectTag();

    ret.setTagId(tagId);
    ret.setObjId(objId);
    ret.setObjType(objType);

    return ret;
  }

}